-
Notifications
You must be signed in to change notification settings - Fork 555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge query parameters coming from path with params
argument
#647
Conversation
01ec2cd
to
fe21618
Compare
The approach looks fine though I wonder if we should add a custom test for the List logic to ensure this is never lost too. It's not the first time we have a weird issue with the upcoming invoice and the fact that it has custom logic on the url and query params. I'd also want to make sure we're not breaking some backwards compatibility logic with Also some tests are failing! |
fe21618
to
6024fe3
Compare
6024fe3
to
0b41357
Compare
If specifying both query parameters in a path/URL down to Faraday (e.g., `/v1/invoices/upcoming?coupon=25OFF`) _and_ query parameters in a hash (e.g., `{ customer: "cus_123" }`), it will silently overwrite the ones in the path with the ones in the hash. This can cause problems where some critical parameters are discarded and causes an error, as seen in issue #646. This patch modifies `#execute_request` so that before going out to Faraday we check whether the incoming path has query parameters. If it does, we decode them and add them to our `query_params` hash so that all parameters from either place are preserved. Fixes #646.
0b41357
to
3a2724b
Compare
Yeah, I see what you mean, but I kind of feel like we should just be testing this stuff where its implementation logic lives. It might have also been plausible to have put this in If
I'm fairly confident this works, but added an extra test just in case that shows that when a parameter in
Rubocop :/ Fixed. |
LGTM |
Thanks! |
Released as 3.13.1. |
I was just working to figure out where this broke, which was v3.8.2. Super impressed at how quickly you guys fixed this! |
@myfitment Thanks, and glad to help! I ran a test script to look at your problem specifically and this seemed to have fixed it pretty definitively, but let us know if you see any other trouble. |
If specifying both query parameters in a path/URL down to Faraday (e.g.,
/v1/invoices/upcoming?coupon=25OFF
) and query parameters in a hash(e.g.,
{ customer: "cus_123" }
), it will silently overwrite the onesin the path with the ones in the hash. This can cause problems where
some critical parameters are discarded and causes an error, as seen in
issue #646.
This patch modifies
#execute_request
so that before going out toFaraday we check whether the incoming path has query parameters. If it
does, we decode them and add them to our
query_params
hash so thatall parameters from either place are preserved.
Fixes #646.
r? @remi-stripe
cc @stripe/api-libraries